package com.gdcn.zb.sys.dao.impl;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.criterion.Expression;
import org.springframework.orm.hibernate3.HibernateCallback;
import com.gdcn.zb.base.BaseDao;
import com.gdcn.zb.base.exception.DaoException;
import com.gdcn.zb.common.page.logic.PageHelper;
import com.gdcn.zb.sys.common.StringUtils;
import com.gdcn.zb.sys.dao.IUserDao;
import com.gdcn.zb.sys.valueobject.User;



public class UserDaoHibernate extends BaseDao implements IUserDao {
	protected Class getModelClass() {
		return User.class;
	}

	public void createUser(User user) throws DaoException {
		super.doCreateObject(user);
		
	}

	public void updateUser(User user) throws DaoException {
		super.doUpdateObject(user);
	}

	public void deleteUser(User user) throws DaoException {	
		super.doDeleteObject(user);		
		super.getSession().flush();
		
	}
	public void deleteUser(String id) throws DaoException {
		super.doDeleteObject(id);		
	}

	public User findUserById(String id) throws DaoException {
		return (User)super.doFindObjectById(id);
	}

	public List findUserBySQL(String hql) throws DaoException {
		return this.getHibernateTemplate().find(hql);
	}

	public List listUser(String hql) throws DaoException {
		return PageHelper.executeQuery(getSession(), hql).list();
	}


}
